The UniLearn registrar needs a course performance report for a fictional 2026 semester. Summarise active enrolments, including students whose scores are not yet available.
Prepare Your PostgreSQL Data
- Open your practice database in pgAdmin Query Tool. Turn Auto-commit on.
- Choose Open File and select the separately supplied
lab5_setup.sql. - Execute the whole file. It selects the
lab5schema. In the same Query Tool, copy the inspection query from Code and confirm 36 rows.
What Does One Row Mean?
One row is one student's enrolment in one course. S101 takes three courses, so S101 appears three times. An enrolment count and a student count can differ.
Build the Registrar's Report
- Count enrolments, recorded scores, and distinct students.
- Calculate totals and averages for each course.
- Keep courses that meet the requested summary conditions.
💡 Read Before Summarising
NULL means no recorded score; 0 is a recorded score. Withdrawn enrolments remain in the table but are excluded from the report.Preview: First 12 of 36 Enrolments
The full enrolments table contains 20 distinct students across six courses. Six withdrawn rows will be filtered out of the report. Run the inspection query to see all 36 rows.
| Enrolment | Student | Programme | Course | Status | Score | Hours |
|---|---|---|---|---|---|---|
| E01 | S101 | DSAI | SQL101 | active | 80 | 6 |
| E02 | S102 | CS | SQL101 | active | 60 | 4 |
| E03 | S103 | DSAI | SQL101 | active | NULL | 5 |
| E04 | S104 | IT | SQL101 | withdrawn | 90 | 2 |
| E05 | S101 | DSAI | PY101 | active | 90 | 8 |
| E06 | S105 | CS | PY101 | active | 50 | 6 |
| E07 | S106 | DSAI | PY101 | active | 70 | 7 |
| E08 | S107 | IT | PY101 | active | NULL | 3 |
| E09 | S102 | CS | VIS101 | active | 40 | 4 |
| E10 | S108 | DSAI | VIS101 | active | NULL | 2 |
| E11 | S109 | IT | VIS101 | withdrawn | 100 | 1 |
| E12 | S110 | IT | VIS101 | active | 0 | 1 |
Read the Columns
enrolment_ididentifies one enrolment;student_idmay repeat.scoreis a mark out of 100, or NULL if unrecorded.study_hoursrecords hours for this enrolment.
💡 PostgreSQL Syntax
Text values use single quotes. Numbers and SQL
NULL do not. End each statement with a semicolon.SET search_path TO lab5;
SELECT *
FROM enrolments
ORDER BY enrolment_id;New Query Tool or Reconnected?
The setup selects the schema for its current connection. Run the following once in a new connection, then use the lesson queries normally.
SET search_path TO lab5;